package org.lld.im.service.friendship.controller;

import org.lld.im.common.ResponseVO;
import org.lld.im.service.friendship.model.req.*;
import org.lld.im.service.friendship.service.ImFriendShipRequestService;
import org.lld.im.service.friendship.service.ImFriendShipService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: LunBoWang
 * @description: 好友申请相关接口
 * @date: 2025/3/14 下午4:46
 * @version: 1.0
 */
@RestController
@RequestMapping("v1/friendshipRequest")
public class ImFriendShipRequestController {
    @Resource
    private ImFriendShipRequestService imFriendShipRequestService;

    //审批好友申请
    @PostMapping("/approveFriendRequest")
    public ResponseVO approveFriendRequest(@Validated @RequestBody ApproverFriendRequestReq req,Integer appId,String identity) {
        req.setAppId(appId);
        req.setOperator(identity);
        return imFriendShipRequestService.approveFriendShip(req);
    }

    //获取好友申请
    @GetMapping("/getFriendRequest")
    public ResponseVO getFriendRequest(@Validated @RequestBody GetFriendShipRequestReq req,Integer appId) {
        req.setAppId(appId);
        return imFriendShipRequestService.getFriendShip(req.getFromId(),req.getAppId());
    }

    //已读好友申请
    @PutMapping("/readFriendRequest")
    public ResponseVO readFriendRequest(@Validated @RequestBody ReadFriendShipRequestReq req,Integer appId) {
        req.setAppId(appId);
        return imFriendShipRequestService.readFriendShipRequest(req);
    }
}
